package com.example.electronicmall.controller;

import java.util.List;

import com.example.electronicmall.to.BusinessOrderTo;
import com.example.electronicmall.service.OrderService;
import com.example.electronicmall.to.OrderDetailTo;
import com.example.electronicmall.to.OrderTo;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;


/**
 * @author mwh
 * @email 1062966353@qq.com
 * @date 2022-12-02 14:48:53
 */
@RestController
@RequestMapping("order")
public class OrderController {
    @Autowired
    private OrderService orderService;

    @PostMapping("/createOrder")
    public String createOrder(@RequestBody OrderTo orderTo){
        return orderService.createOrder(orderTo);
    }

    @PostMapping("/listOrdersByUserId")
    public List<OrderDetailTo> listOrdersByUserId(Integer userId){
        return orderService.listOrdersByUserId(userId);
    }

    @PostMapping("/listOrdersByBusinessId")
    public List<BusinessOrderTo> listOrdersByBusinessId(Integer businessId){
        return orderService.listOrdersByBusinessId(businessId);
    }

    @PostMapping("/receiveOrder")
    public void receiveOrder(String orderId){
        orderService.receiveOrder(orderId);
    }

    @PostMapping("/rejectOrder")
    public void rejectOrder(String orderId){
        orderService.rejectOrder(orderId);
    }

    @PostMapping("/payOrder")
    public void payOrder(String orderId){
        orderService.payOrder(orderId);
    }

    @PostMapping("/deleteOrder")
    public void deleteOrder(String orderId){
        orderService.deleteOrder(orderId);
    }
}
